//
//  GameViewController.m
//  PlaneWar2
//
//  Created by HappyMilk 02 on 2017/3/28.
//  Copyright © 2017年 HappyMilk 02. All rights reserved.
//

#import "GameViewController.h"
#import "GameScene.h"

@implementation GameViewController{
    
    SKView *skView;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    // Load the SKScene from 'GameScene.sks'
    GameScene *scene = [GameScene sceneWithSize:self.view.bounds.size];
    scene.scaleMode = SKSceneScaleModeAspectFill;
    skView = (SKView *)self.view;
    
    if (_sceneType == 1) {
        scene.gameType = 1;
    }else if (_sceneType == 2){
        scene.gameType = 2;
    }else if (_sceneType == 3){
        scene.gameType = 3;
    }else if (_sceneType == 4){
        scene.gameType = 4;
    }else{
        scene.gameType = 5;
    }
    [skView presentScene:scene];
    
    
    
    //skView.showsFPS = YES;
    //skView.showsNodeCount = YES;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss) name:@"dismiss" object:nil];
}
- (void)dismiss{
    
    [self.presentingViewController.presentingViewController dismissViewControllerAnimated:NO completion:^{
        [skView presentScene:nil];
    }];
}

- (BOOL)shouldAutorotate {
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    } else {
        return UIInterfaceOrientationMaskAll;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

- (BOOL)prefersStatusBarHidden {
    return YES;
}

@end
